package com.example.qxfw.qxxx.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.qxfw.common.entity.yj.WarnSignalInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.sql.Timestamp;
import java.util.List;

@Mapper
//@DS("qx")，之前的mapper使用的是qx数据库，现在改为service数据库
@DS("service")
public interface WarnSignalInfoMapper extends BaseMapper<WarnSignalInfo> {

    @Select("select announcedtime, area, Type, color, signatory, watch, standard, defenseguide, id, pos, row_number() over (partition by announcedtime order by id asc) as joinid " +
            "from warn_signal_info " +
            "where bfree=0 and city like concat('%',#{stationName},'%') and announcedtime between #{pdtStart} and #{pdtEnd} " +
            "order by announcedtime DESC ")
    List<WarnSignalInfo> selectList(@Param("stationName") String stationName, @Param("pdtStart") Timestamp pdtStart, @Param("pdtEnd") Timestamp pdtEnd);

    @Select("select area " +
            "from warn_signal_info " +
            "where bfree=0 and city like concat('%',#{stationName},'%') and announcedtime=#{time} " +
            "order by id")
    List<String> selectArea(@Param("stationName") String stationName, @Param("time") Timestamp time);


    //查询所有城市
    @Select("select distinct city " +
            "from warn_signal_info " +
            "where bfree=0 " +
            "order by city")
    List<String> selectCity();
}
